package com.wenguodong.demofirstt;

import jakarta.validation.ConstraintViolation;
import jakarta.validation.Validator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;

import java.util.Set;

/*
 *@Time：2023/4/19
 *@Author：Jelly
 */
@Service
public class uhjk {

//    @Autowired
//    private Validator validator;
    @Autowired
    private org.springframework.validation.Validator validator;

    public  boolean validator(UserT user){

        BindException bindException = new BindException(user, user.getName());
        validator.validate(user,bindException);
        return bindException.hasErrors();
    }

}
